﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IRepository;
using Models;
using Infrastructures;

namespace RepositoryMySQL
{
    public class CommonRepository : ICommonRepository
    {
        internal CommonRepository() { }

        public virtual T Create<T>(T obj)
        {
            MethodHelper.ExecuteMethod(MethodType.Create, obj);
            return obj;
        }

        public virtual void Update<T>(T obj)
        {
            MethodHelper.ExecuteMethod(MethodType.Update, obj);
        }

        public virtual void Delete<T>(string code)
        {
            MethodHelper.ExecuteMethod(MethodType.Delete, typeof(T), code);
        }

        public virtual List<T> List<T>()
        {
            return (List<T>)MethodHelper.ExecuteMethod(MethodType.List, typeof(T));
        }

        public T Get<T>(string code)
        {
            return (T)MethodHelper.ExecuteMethod(MethodType.Get, typeof(T), code);
        }
    }
}
